package com.hckj.jianzhijia.popupwindows;

import android.content.Context;
import android.view.View;

import com.hckj.jianzhijia.model.Province;
import com.hckj.jianzhijia.utils.Data;

import java.util.ArrayList;

/**
 * Created by 赵奇隆 on 2015-10-29.
 */
public class PublishPopupWindowProvince  extends ListPopupWindow {

    private PublishPopWinProvinceInterface publishPopWinProvinceInterface;
    private ArrayList<Province> provinces;



    public static PublishPopupWindowProvince newInstance(Context context,PublishPopWinProvinceInterface publishPopWinProvinceInterface, View parentView,ArrayList<Province> provinces){

        String[] dataArray = new String[provinces.size()];
        for(int i=0,j=provinces.size();i<j;i++){
            dataArray[i] =  provinces.get(i).getProvince();
        }
        return new PublishPopupWindowProvince(context, publishPopWinProvinceInterface, parentView, provinces,dataArray);
    }

    public PublishPopupWindowProvince(Context context,PublishPopWinProvinceInterface publishPopWinProvinceInterface, View parentView, ArrayList<Province> provinces, String[] dataArray) {
        super(context, parentView, null, dataArray);
        this.publishPopWinProvinceInterface = publishPopWinProvinceInterface;
        this.provinces = provinces;
    }


    public  interface PublishPopWinProvinceInterface{
        public void setProvince(int position,String itemName);
    }

    @Override
    public void getListItem(int position, String itemName) {
        publishPopWinProvinceInterface.setProvince(provinces.get(position).getProvinceId(), itemName);
    }

}
